package org.wattdepot.cli.processor;

import java.util.List;
import org.wattdepot.cli.command.WattSensorDataTime;

/**
 * Parses the sensordata command.
 * 
 * @author Kendyll Doi
 * @author Kimberly Heu
 *
 */
public class SensorDataCommand  extends CommandLineInterface implements WattDepotCliCommand {
  
  /**
   * Parses the sensordata command.
   * 
   * @param args The arguments of the users command.
   * @return The string from executing the command.
   */
  public String doCommand(List<String> args) {
    StringBuffer buf = new StringBuffer(200); // Buffer to store return information
    String output = ""; // String for output
    
    if (args.size() == 4) {
      if (args.get(2).equalsIgnoreCase("timestamp")) {
        // Command has correct form, so get the required information
        buf.append(WattSensorDataTime.wattSensorDataTime(args.get(1), args.get(3), client));
      }
      else {
        // Return an error message if command does not have the correct form
        buf.append("Incorrect syntax for sensordata command.");
      }
    }
    else {
      // Return an error message if there are an incorrect number of arguments
      buf.append("Incorrect number of arguments for sensordata command");
    }
    
    output = buf.toString();
    return output;
  }
}
